﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Telerik.Windows.Controls;

namespace ContactList
{
    public partial class Default : Page
    {
        #region Members
        private ContactServices.ContactServicesClient client;
        #endregion
        
        public Default()
        {
            InitializeComponent();

            // Call up web service
            client = new ContactServices.ContactServicesClient();
            client.GetAllContactsCompleted += client_GetAllContactsCompleted;
            client.GetAllContactsAsync();
        }

        void client_GetAllContactsCompleted(object sender, ContactServices.GetAllContactsCompletedEventArgs e)
        {
            ContactDataGrid.ItemsSource = e.Result;
            client.CloseAsync();
            MessageBox.Show("Web service returns.");
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }
    }
}
